<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>
  //  [1,1,1,2,2,3,4,5,6,3,4,2,4,1,] ---> [1,2,3,4,5,6]

  //定义方法
  function noRepeat(arr){
    var myArr = [];
    for(var i = 0; i< arr.length; i++){
      var char = arr[i];
      if(myArr.indexOf(char) == -1){
          myArr.push(char);
      }
    }
    return myArr;
  }

  var arr = [1,1,1,2,2,3,4,5,6,3,4,2,4,1,];
  console.log(noRepeat(arr));
</script>
</html>